<template>
	<view>
		dashboard
		
	</view>
</template>

<script>
	import {
		apis,
		routes
	} from '@/common/paths.js'
	export default {
		data() {
			return {
				project_id: uni.getStorageSync('project_id'),
				user_token : uni.getStorageSync('user_token'),
			};
		},
		onLoad(e) {
			console.log("e: " + JSON.stringify(e));
			uni.setStorageSync('project_id', e.project_id)
			this.project_id = e.project_id
			if (!this.user_token) {
				uni.switchTab({
					url: routes['index']
				})
			}else if(!this.project_id){
				console.log('not project_id')
				// let currentPages = getCurrentPages()
				// console.log('currentPages:',currentPages);
				uni.switchTab({
					url: routes['project_list']
				});
			}else {
				uni.request({
					url: this.backendServer + apis['do_dashboard'],
					method: 'get',
					// dataType:'application/json',
					data: {
						'user_id': this.user_token,
						'project_id': this.project_id
					},
					success: (res) => {
						uni.hideLoading()
						console.log('success res ', res)
						if (res.data.status) {
							console.log('request ok')

							console.log("dashboard info : " + JSON.stringify(res.data));
						} else {
							uni.showToast({
								title: "获取失败，请检查用户名或密码",
								icon: 'fail'
							})
						}
					},
					fail: (res) => {
						uni.hideLoading()
						console.log('fail res ', res)
						uni.showToast({
							title: "获取失败，请检查网络联接",
							icon: 'fail'
						})
					}
				})
			}

		}
	}
</script>

<style lang="scss">

</style>